# file name: app/network_monitor/agent/monitor_agent_factory.py
from typing import Dict, Type, List
from .base_monitor_agent import BaseMonitorAgent


class MonitorAgentFactory:
    """Factory class for creating and managing monitoring agents."""

    _agent_classes: Dict[str, Type[BaseMonitorAgent]] = {"zabbix": ZabbixMonitorAgent}

    @classmethod
    def create_agent(cls, agent_type: str, config: Dict) -> BaseMonitorAgent:
        """Create a monitoring agent of the specified type.

        Args:
            agent_type: Type of agent to create
            config: Configuration dictionary for the agent

        Returns:
            BaseMonitorAgent: Configured monitoring agent instance

        Raises:
            ValueError: If agent_type is not supported
        """
        if agent_type not in cls._agent_classes:
            raise ValueError(f"Unsupported agent type: {agent_type}")

        agent = cls._agent_classes[agent_type]()
        agent.configure(config)
        return agent

    @classmethod
    def get_supported_agent_types(cls) -> List[str]:
        """Get list of supported agent types.

        Returns:
            List[str]: Supported agent type identifiers
        """
        return list(cls._agent_classes.keys())
